package com.slkj.shilixiaoyuanapp.ui.user.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.entity.PersonCenterEntity;
import com.slkj.shilixiaoyuanapp.entity.UserEntity;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class PersonHeadAdapter extends BaseQuickAdapter<UserEntity.StudentEntity ,BaseViewHolder> {
    private Context context;

    public PersonHeadAdapter(@Nullable List<UserEntity.StudentEntity> picPaths, Context context) {
        super(R.layout.item_person_head, picPaths);
        this.context = context;
    }



    @Override
    protected void convert(BaseViewHolder helper, UserEntity.StudentEntity item) {
        TextView tv_name=helper.getView(R.id.tv_name);
        TextView tv_grade=helper.getView(R.id.tv_grade);
        RelativeLayout rl_img_teacher_head=helper.getView(R.id.rl_img_teacher_head);
//        Glide.with(context).load(item.getHeadpath()).into((ImageView) helper.getView(R.id.img_head));
        if (item.getIsSelect()==1) {
            //helper.getView(R.id.img_choose).setVisibility(View.VISIBLE);
            tv_name.setTextColor(Color.parseColor("#0087FC"));
            tv_grade.setTextColor(Color.parseColor("#0087FC"));
            rl_img_teacher_head.setAlpha(1f);
        }else {
            //helper.getView(R.id.img_choose).setVisibility(View.GONE);
            tv_name.setTextColor(Color.parseColor("#666666"));
            tv_grade.setTextColor(Color.parseColor("#666666"));
            rl_img_teacher_head.setAlpha(0.5f);
        }
        TextView name = helper.getView(R.id.tv_name);
        name.setText(item.getName());
        TextView grade = helper.getView(R.id.tv_grade);
        grade.setText(item.getClassName());
        CircleImageView head=helper.getView(R.id.img_teacher_head);
        Glide.with(context).load(item.getHead()).asBitmap().centerCrop().error(R.drawable.ic_man).placeholder(R.drawable.ic_man).into(head);
        ImageView iv_sex=helper.getView(R.id.img_choose);
        if (item.getSex()==0){
            Glide.with(context).load(R.drawable.girl).asBitmap().centerCrop().into(iv_sex);
        }else {
            Glide.with(context).load(R.drawable.boy).asBitmap().centerCrop().into(iv_sex);
        }

    }
}
